<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-teachWeisheng-edit" th:object="${teachWeisheng}">
            <input id="wid" name="wid" th:field="*{wid}"  type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">教室或者宿舍号码：</label>
				<div class="col-sm-8">
					<input id="wno" name="wno" th:field="*{wno}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">得分：</label>
				<div class="col-sm-8">
					<input id="wscore" name="wscore" th:field="*{wscore}" class="form-control" type="text">
				</div>
			</div>
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">班主任编号：</label>
				<div class="col-sm-8">
					<input id="wteacher" name="wteacher" th:field="*{wteacher}" class="form-control" type="text">
				</div>
			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">班主任：</label>
				<div class="col-sm-8">
					<input id="wteachername" name="wteachername" th:field="*{teacherName}" class="form-control" onclick="selectTeacherList()" type="text">
					<input id="wteacher" name="wteacher"  th:field="*{wteacher}" class="form-control"  type="hidden">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">班级名称：</label>
				<div class="col-sm-8">
					<input class="form-control" th:field="*{className}"  type="text" name="className" onclick="selectList()"  id="className">
					<input id="wcid" name="wcid" th:field="*{wcid}" class="form-control" type="hidden">
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">时间：</label>
				<div class="col-sm-8">
					<input id="wdate" name="wdate" th:field="*{wdate}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="wbeizhu" name="wbeizhu" th:field="*{wbeizhu}" class="form-control" type="text">
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "teach/teachWeisheng";
		$("#form-teachWeisheng-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-teachWeisheng-edit').serialize());
	        }
	    }

		$(function(){
			//时间选择器
			laydate.render({
				elem: '#wdate',trigger: 'click'
			});
		});

		function selectTeacherList() {
			var url = ctx + "system/user/selectListDept?did=158";		//查询教质部的老师
			var options = {
				title: '选择老师',
				width: "800",
				url: url,		//教质部
				callBack: TeacherOpen
			};
			$.modal.openOptions(options);
		}
		function TeacherOpen(index, layero){
			//获取相对应的隐藏域的值
			//var indexs =this.data.previousSibling.previousSibling.value;
			var body = layer.getChildFrame('body', index);
			var data = body.find('.selected')[0];
			if(data != "undefined" && data != "" && data != null){

				var tname = data.children[2].innerHTML;	//老师名字
				var tid = data.children[1].innerHTML;
				$("#wteachername").val(body.find('.selected')[0].children[2].innerHTML);
				$("#wteacher").val(body.find('.selected')[0].children[1].innerHTML);
				/*for(var i=0;i<$(".trs").length;i++){
					if(i==indexs){
						$(".trs").eq(i).children().eq(10).children().eq(2).val(data.children[2].innerHTML);
						$(".trs").eq(i).children().eq(10).children().eq(0).val(data.children[1].innerHTML);
						//console.log($(".trs").eq(i).children().eq(9).children().eq(0).val());
					}
				}*/
			}else{
				layer.msg("请选择一个老师");
			}
			layer.close(index);
		}

		/*学生管理-新增-选择班级*/
		function selectList() {
			var url = ctx + "teach/teachClasses/selectList";
			var options = {
				title: '选择班级',
				width: "800",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}

		function doSubmit(index, layero){
			var body = layer.getChildFrame('body', index);
			var data = body.find('.selected')[0];
			if(data != "undefined" && data != "" && data != null){
				$("#className").val(body.find('.selected')[0].children[2].innerHTML);
				$("#wcid").val(body.find('.selected')[0].children[1].innerHTML);
			}else{
				layer.msg("请选择一个班级");
			}
			layer.close(index);
		}
	</script>
</body>
</html>
